package homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortReducer extends Reducer<LongWritable,LongWritable,LongWritable,LongWritable> {

    private static LongWritable index_col = new LongWritable(1);
    @Override
    protected void reduce(LongWritable key, Iterable<LongWritable> values, Context context)
            throws IOException, InterruptedException {
        //利用shuffule机制的快速排序
        for(LongWritable v:values){
            context.write(index_col,key);
            index_col = new LongWritable(index_col.get() + 1);
        }
    }
}
